/**
 * 
 */
package edu.arizona.bio5.onto.decomposition;

import java.util.Set;

import edu.arizona.bio5.onto.decomposition.locality.SeedSigFinderWithExtraction;

/**
 * Assigns each atom a label containing a (possible incomplete) set of seed signatures
 * 
 * @author Pavel Klinov
 *
 */
public class MSSLabelingAlgorithm implements AtomLabelingAlgorithm {

	/* 
	 */
	@Override
	public void compute(AtomicDecomposition ad) {

		SeedSigFinderWithExtraction ssFinder = new SeedSigFinderWithExtraction(ad.getModuleType());
		
		for (Atom atom : ad.getAtoms()) atom.removeLabel(MSSLabel.TYPE);
		
		Set<Atom> topAtoms = ad.getTopAtoms();
		int i = 0;
		int step = Math.max(1, topAtoms.size() / 10);
		
		for (Atom atom : topAtoms) {
			
			if (++i % step == 0) System.out.println("Labeling, " + (100* i / topAtoms.size()) + "% completed");
			
			ssFinder.findMinSeedSignatures(atom, ad);
		}
		//Build the term-based index
		new MSSBasedADIndexBuilder().index(ad);
	}
}
